package com.qsh.ts.mem;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by sehuaqi on 2017/6/24.
 */
@Controller
public class MainController {

    @Autowired
    private MemService service;

    @RequestMapping("/")
    public String main(){

        System.out.println(">>>>>");

        return "main";
    }

    @RequestMapping("/queryTimershaft")
    @ResponseBody
    public List queryTimershaft(){

        List<Timer> times = new ArrayList<>();
        Timer timer = new Timer();
        timer.setT("2019");
        timer.setC("凤凰涅槃");
        times.add(timer);

        timer = new Timer();
        timer.setT("2018");
        timer.setC("迎接新的一年");
        times.add(timer);

        timer = new Timer();
        timer.setT("2017");
        timer.setC("开启新的篇章");
        times.add(timer);


        timer = new Timer();
        timer.setT("2017");
        timer.setC("开启新的篇章");
        times.add(timer);


        timer = new Timer();
        timer.setT("2016");
        timer.setC("对未来美好的展望");
        times.add(timer);

        timer = new Timer();
        timer.setT("2015");
        timer.setC("平凡的一年");
        times.add(timer);

        timer = new Timer();
        timer.setT("2014");
        timer.setC("一次蜕变");
        times.add(timer);

        times = service.queryTimershaft();


        return times;
    }

    @RequestMapping("/addTimershaft/{t}/{c}")
    @ResponseBody
    public String addTimershaft(@PathVariable String t,@PathVariable String c){


        String result = service.addTimershaft(t, c);

        return result;
    }

}
